home *** CD-ROM | disk | FTP | other *** search
- /* clearerr.c */
- #include <stdio.h>
- void clearerr(FILE *infile);
- main()
- {
- char file1[81];
- FILE *infile;
- long filesize;
- printf ("Enter the name of an existing file: ");
- gets(file1);
- /* Open the file */
- if ((infile = fopen(file1, "r")) == NULL)
- {
- printf ("fopen failed to open: %s\n", file1);
- exit(0);
- }
- fprintf(infile, "Test..."); /* Try to read a line */
- if (ferror(infile) != 0) /* Check for the error */
- {
- printf("Error detected\n");
- clearerr(infile); /* Now clear the error */
- rintf("Error cleared\n");
- }
- }